﻿using AiXiu.BLL;
using AiXiu.IBLL;
using AiXiu.Model;
using System;
using System.Web.UI;

namespace AiXiu.WebSite
{
    /// <summary>
    /// 视频播放页
    /// </summary>
    public partial class Play : Page
    {
        public string VideoId;
        public int UserId;
        public TBVideos Video;
        public TBUsers Author;
        public GetPlayInfoResult playInfo;
        public bool IsLike = false;
        public long LikeCount = 0;
        public long DiscussCount = 0;

        protected void Page_Load(object sender, EventArgs e)
        {
            if(!IsPostBack)
            {
                VideoId = Request.QueryString["id"];
                IVideoBLL videoBLL = new VideoBLL();
                //从数据库获取视频基本信息
                Video = videoBLL.GetVideoByVideoId(VideoId);
                TBUsers user = IdentityManager.ReadUser();
                UserId = user.Id;
                Author = Video.TBUsers;

                //从阿里云获取视频播放信息
                playInfo = videoBLL.Initplay(VideoId);

                //获取点赞数量和是否点赞
                ILikeManager likeManager = new LikeManager();
                LikeCount = likeManager.Count(VideoId);
                IsLike = likeManager.IsLike(VideoId, UserId);

                //获取评论数量
                IDiscussManager discussManager = new DiscussManager();
                DiscussCount = discussManager.Count(VideoId);
            }
        }
    }
}